%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Welcome to writeLaTeX --- just edit your LaTeX on the left,
% and we'll compile it for you on the right. If you give
% someone the link to this page, they can edit at the same
% time. See the help menu above for more info. Enjoy!
%
% Note: you can export the pdf to see the result at full
% resolution.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Line plot example using external data fiels.
%
% Author: Claudio Favi


\documentclass[letterpaper,12pt,titlepage]{article}
\usepackage{array}
\usepackage{graphicx}
\usepackage{float}
\usepackage{courier}
\usepackage{ulem}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{plotmarks}

%%%<
\usepackage{verbatim}
%\usepackage[active,tightpage]{preview}
%\PreviewEnvironment{tikzpicture}
%\setlength\PreviewBorder{5pt}%
%%%>

\begin{comment}
:Title:  Line Plot Example
:Tags: Plotting; Plots
:Author: Claudio Favi
\end{comment}

% The data files, written on the first run.
\begin{filecontents}{put.data}
#droprate 	ratio
5	0.84
10	0.72
15	0.65
20	0.58
25	0.47
30	0.36
35	0.35
40	0.30
45	0.28
50	0.21
\end{filecontents}

\begin{filecontents}{get.data}
#droprate 	ratio
5	 0.87
10	0.79
15	0.62
20	0.54
25	0.47
30	0.45
35	 0.37
40	 0.36
45	0.23
50	0.21 
\end{filecontents}


\begin{document}

\title{COMP6461}
\setcounter{tocdepth}{2}
\newpage
\begin{center}
{\bf\ COMP6461:Communication Network \& Protocols}

$\mathcal{L}$ab $\mathcal{A}$ssignment 2

$\mathcal{P}$erformance $\mathcal{E}$valuation

\vspace{1cm}
\hspace{1cm} Student:Xiaodong Li \hspace{5cm} Student ID:7136609 \hspace{1cm}
\vspace{0.1cm}
\uuline{
\hspace{1cm} Student:Xuefei Shi \hspace{5.15cm} Student ID:6832407 \hspace{1cm}
}
\vspace{0.1cm}
\end{center}
\begin{enumerate}
\item File Transfer Data Collected

The following two table contains the neccesary data we need to compute the ratio of minimum required packet number and actual number of packets sent when the drop rate of packets changes.

As the results vary, for each drop rate, we did three times of put function and three times of get function, and used the average result for further computation.

In all the testing work, we used an binary file size of 3400 bytes, which could be divided into 14 packets.
\begin{table}[H]
\begin{tabular}{l|llllll}
drop rate & required & actual 1 & actual 2 & actual 3 & avg actual & ratio \\ \hline
5\%       & 14       & 15       & 17       & 18       & 16.67      & 0.84  \\
10\%      & 14       & 19       & 20       & 19       & 19.33      & 0.72  \\
15\%      & 14       & 21       & 25       & 19       & 21.67      & 0.65  \\
20\%      & 14       & 28       & 21       & 23       & 24.00      & 0.58  \\
25\%      & 14       & 29       & 31       & 30       & 30.00      & 0.47  \\
30\%      & 14       & 41       & 41       & 35       & 39.00      & 0.36  \\
35\%      & 14       & 35       & 36       & 48       & 39.67      & 0.35  \\
40\%      & 14       & 52       & 42       & 45       & 46.33      & 0.30  \\
45\%      & 14       & 39       & 48       & 60       & 49.00      & 0.28  \\
50\%      & 14       & 85       & 59       & 58       & 67.33      & 0.21 
\end{tabular}
\caption{PUT}
\label{my-label}
\end{table}

\begin{table}[H]
\begin{tabular}{l|llllll}
drop rate & required & actual 1 & actual 2 & actual 3 & avg actual & ratio \\ \hline
5\%       & 14       & 17       & 17       & 14       & 16.00      & 0.87  \\
10\%      & 14       & 17       & 19       & 17       & 17.67      & 0.79  \\
15\%      & 14       & 14       & 19       & 18       & 22.33      & 0.62  \\
20\%      & 14       & 28       & 27       & 22       & 25.67      & 0.54  \\
25\%      & 14       & 31       & 29       & 30       & 30.00      & 0.47  \\
30\%      & 14       & 34       & 32       & 28       & 31.33      & 0.45  \\
35\%      & 14       & 35       & 35       & 43       & 37.67      & 0.37  \\
40\%      & 14       & 42       & 32       & 43       & 39.00      & 0.36  \\
45\%      & 14       & 56       & 72       & 55       & 61.00      & 0.23  \\
50\%      & 14       & 67       & 77       & 61       & 68.33      & 0.21 
\end{tabular}
\caption{GET}
\label{my-label}
\end{table}

\item Ratio-Drop rate Graph

 With the data we collected, we could come up with the following graph.
 
 And we can tell from the graph, for both PUT and GET function, that the ratio of required packet number and actual packet number sent becomes smaller when the drop rate increases.
 
 As the required number of packet is fixed in our testing, this means, the higher the drop rate is, the more packets we need to send to guarantee the reliability of the file transfer protocol we designed.

\begin{tikzpicture}[y=3.7cm, x=.3cm,font=\sffamily]
 	%axis
	\draw (0,0) -- coordinate (x axis mid) (50,0);
    	\draw (0,0) -- coordinate (y axis mid) (0,1);
    	%ticks
    	\foreach \x in {0,5,...,50}
     		\draw (\x,1pt) -- (\x,-3pt)
			node[anchor=north] {\x};
    	\foreach \y in {0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1}
     		\draw (1pt,\y) -- (-3pt,\y) 
     			node[anchor=east] {\y}; 
	%labels      
	\node[below=0.8cm] at (x axis mid) {drop rate(\%)};
	\node[rotate=90, above=0.8cm] at (y axis mid) {ratio};

	%plots
	\draw plot[mark=*, mark options={fill=white}] 
		file {put.data};
	\draw plot[mark=* ] 
		file {get.data};
	 
    
	%legend
	\begin{scope}[shift={(3,0.35)}] 
	\draw (0,0) -- 
		plot[mark=*, mark options={fill=white}] (0.25,0) -- (0.5,0) 
		node[right]{put};
	\draw[yshift=\baselineskip] (0,0) -- 
		plot[mark=*] (0.25,0) -- (0.5,0)
		node[right]{get};
	
	\end{scope}
\end{tikzpicture}
\end{enumerate}
\end{document}